#include "../src_baseClasses/TabPage.h"

//1.包含所需头文件
#include "TabPage_grid/TabPage_grid.h"		//(1)gid网格类地图
#include "TabPage_lines/TabPage_lines.h"		//(2)dsn类PCB文件
#include "TabPage_dsn/TabPage_dsn.h"		//(2)dsn类PCB文件

namespace {
	// 2.定义构造函数
	static auto fun_grid = [](	//(1)gid网格类地图
		const QString& qFullName, const QString& qFilePath, const QString& qFileName, QWidget* parent) {
			return new TabPage_grid(qFullName, qFilePath, qFileName, parent);
		};
	static auto fun_lines = [](	//(2)post类后处理文件
		const QString& qFullName, const QString& qFilePath, const QString& qFileName, QWidget* parent) {
			return new TabPage_lines(qFullName, qFilePath, qFileName, parent);
		};
	static auto fun_dsn = [](	//(3)dsn类PCB文件
		const QString& qFullName, const QString& qFilePath, const QString& qFileName, QWidget* parent) {
			return new TabPage_dsn(qFullName, qFilePath, qFileName, parent);
		};

	struct TabPageRegister {
		TabPageRegister() {
			TabPageFactory& factory = TabPageFactory::instance();
			std::vector<QString> suffixes;

			// 3.注册构造函数
			suffixes = { "jpg", "png", "jpeg", "map", "json" };		//(1)gid网格类地图,不区分大小写
			for (const auto& suffix : suffixes) {
				factory.registerCreator(suffix, fun_grid);
			}

			suffixes = { "lines" };						//(2)lines类矢量地图,不区分大小写
			for (const auto& suffix : suffixes) {
				factory.registerCreator(suffix, fun_lines);
			}

			suffixes = { "dsn" };									//(3)dsn类PCB文件
			for (const auto& suffix : suffixes) {
				factory.registerCreator(suffix, fun_dsn);
			}


		}
	};
	TabPageRegister registrar_grid;
}
